#!pip install ipywidgets matplotlib scipy numpy ipympl
%matplotlib widget
from matplotlib import pyplot as plt
from scipy.stats import johnsonsu, norm, t
from ipywidgets import interact, widgets
import numpy as np
This is a little demo on how to make interactive plots with matplotlib and ipympl.
= np.linspace(-5, 5, 1000)
x
= plt.figure()
fig ="normal")
plt.plot(x, norm.pdf(x), label= plt.plot(x, x, label="other")
line,
plt.legend()0, 1)
plt.ylim(
def update(a, b, which):
if which == "Johnson SU":
= johnsonsu.pdf(x, a, np.exp(b))
y elif which == "Student-t":
= t.pdf(x, np.exp(b))
y
line.set_ydata(y)
fig.canvas.draw_idle()
interact(update,=(-10.0, 10.0),
a=widgets.FloatSlider(0.0, min=-10.0, max=5.0),
b=["Johnson SU", "Student-t"]); which